package com.bestom.sharingbookcase.services;

import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;

public class WifiConfig {
    private static final String WIFISP = "WifiConfig";

//    private static final String WIFI_SSID = "k802ap";

    private static final String WIFI_SSID = "TP-LINK_24_EF88";
    private static final String WIFI_PASSWORD = "12345678";

    public static void setWifiInfo(Context context, String ssid, String pwd) {

        if (TextUtils.isEmpty(ssid)) {
            return;
        }

        if (TextUtils.isEmpty(pwd)) {
            return;
        }

        SharedPreferences sp = context.getSharedPreferences(WIFISP, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sp.edit();
        editor.putString("ssid", ssid);
        editor.putString("pwd", pwd);
        editor.commit();
    }

    public static String[] getWifiInfo(Context context) {

        SharedPreferences sp = context.getSharedPreferences(WIFISP, Context.MODE_PRIVATE);
        String ssid = sp.getString("ssid", "");
        String pwd = sp.getString("pwd", "");
        if (TextUtils.isEmpty(ssid)) {
            ssid = WIFI_SSID;
            pwd = WIFI_PASSWORD;
        }

        return new String[]{ssid, pwd};
    }
}
